package com.cx.controller;

import com.mysql.cj.Session;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class login {
    @RequestMapping("/login.do")
    @ResponseBody
    private String login(@RequestBody List<String> user,HttpServletRequest request){
        if(user.get(1) .equals("admin")){

            request.getSession().setAttribute("user",user);

            return "success";
        }
        return "fail";
    }
}
